package ubadbtools.recoveryLogAnalyzer.redo.common.logRecords;

import java.util.LinkedHashSet;
import java.util.Set;

public class StartCheckPointLogRecord extends RecoveryLogRecord
{
	private Set<String> activeTransactions;
	
	public StartCheckPointLogRecord(Set<String> transactions) 
	{
		this.activeTransactions = new LinkedHashSet<String>(transactions);
	}
	
	public Set<String> getTransactions()
	{
		return activeTransactions;
	}
	
	public String toString()
	{
		return "<START CKPT " + activeTransactions.toString() + ">"; 
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime
				* result
				+ ((activeTransactions == null) ? 0 : activeTransactions
						.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		StartCheckPointLogRecord other = (StartCheckPointLogRecord) obj;
		if (activeTransactions == null) {
			if (other.activeTransactions != null)
				return false;
		} else if (!activeTransactions.equals(other.activeTransactions))
			return false;
		return true;
	}
}
